/*
Author: Leif Erkenbrach
Class: CSI240-01
Assignment: Lab 7
Date Assigned: 09/05/12
Due Date: N/A
Description: This program creates a linked list that adds elements based on alphebetical order.
Certification of Authenticity:
I certify that this assignment is entirely my own work.
*/
#include "main.h"

void main()
{
	//LinkedList theList;
    SortedLinkedList theList;

	cout << "Initial words added!\nwords:" << theList.getReport() << endl;

	ifstream inFile( "ListDriver.txt" );

	if( inFile.good() )
	{
		while( !inFile.eof() )
		{
			//read a command
			char command;
			inFile >> command;
			processCommand( inFile, command, theList );
		}
	}
	else
	{
		cout << "File not found!\n";
	}
	system( "pause" );
}

void processCommand( ifstream& inFile, char command, LinkedList& theList )
{
	switch( command )
	{
	case 'A'://add a word
		{
			//read a word
			string word;
			inFile >> word;

			//add word to list
			theList.addWord( word );

			//confirm
			cout << "word:" << word << " added\n";
		}
		break;
	case 'R'://remove a word
		{
			//read a word
			string word;
			inFile >> word;

			//remove the node
			theList.removeWord( word );

			//confirm
			cout << "word:" << word << " removed\n";
		}
		break;
	case 'D'://delete all nodes
		{
			theList.removeAllWords();

			//confirm
			cout << "All Nodes removed!" << endl;

		}
		break;
	case 'P'://print report of all nodes
		{
			cout << "Nodes:" << theList.getReport() << endl;
		}
		break;
	default:
		cout << "Shouldn't get here!\n\n";
	}
}

void processCommand( ifstream& inFile, char command, SortedLinkedList& theList )
{
	switch( command )
	{
	case 'A'://add a word
		{
			//read a word
			string word;
			inFile >> word;

			//add word to list
			theList.addWord( word );

			//confirm
			cout << "word:" << word << " added\n";
		}
		break;
	case 'R'://remove a word
		{
			//read a word
			string word;
			inFile >> word;

			//remove the node
			theList.removeWord( word );

			//confirm
			cout << "word:" << word << " removed\n";
		}
		break;
	case 'D'://delete all nodes
		{
			theList.removeAllWords();

			//confirm
			cout << "All Nodes removed!" << endl;

		}
		break;
	case 'P'://print report of all nodes
		{
			cout << "Nodes:" << theList.getReport() << endl;
		}
		break;
	default:
		cout << "Shouldn't get here!\n\n";
	}
}

/*void processCommand( ifstream& inFile, char command, BackwardLinkedList& theList )
{
	switch( command )
	{
	case 'A'://add a word
		{
			//read a word
			string word;
			inFile >> word;

			//add word to list
			theList.addWord( word );

			//confirm
			cout << "word:" << word << " added\n";
		}
		break;
	case 'R'://remove a word
		{
			//read a word
			string word;
			inFile >> word;

			//remove the node
			theList.removeWord( word );

			//confirm
			cout << "word:" << word << " removed\n";
		}
		break;
	case 'D'://delete all nodes
		{
			theList.removeAllWords();

			//confirm
			cout << "All Nodes removed!" << endl;

		}
		break;
	case 'P'://print report of all nodes
		{
			cout << "Nodes:" << theList.getReport() << endl;
		}
		break;
	default:
		cout << "Shouldn't get here!\n\n";
	}
}*/
